<?php
/*
 * 理论上会 get 来的参数
 * $class
 * $index_
 */
if (!isset($_GET["class"]) || !isset($_GET["index_"])) {
    die("GET 参数未指定");
}
$class = $_GET["class"];
$index_ = $_GET["index_"];

try {
//  $connPdo = new PDO("mysql:host=127.0.0.1:3306;dbname=test;charset=utf8", "root", "");
    $connPdo = new PDO('mysql:host=localhost;dbname=test;charset=utf8', 'squidward_top', '789456');
    $connPdo->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);


    $statement = "SELECT * FROM test.$class\nWHERE index_ = $index_";
    $records = $connPdo->query($statement)->fetchAll();

    echo json_encode($records);
} catch (PDOException $e) {
    die("die 了，以下回显是人为输出的 =>\n{$e->getMessage()}");
}
